package com.example.imtoken.modules.welcome

import android.os.CountDownTimer
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.SPUtils
import com.example.imtoken.R
import com.example.imtoken.core.base.BaseActivity
import com.example.imtoken.core.utils.sp.SpHelps
import com.example.imtoken.databinding.ActivityWelcomeBinding
import com.example.imtoken.modules.login.LoginActivity
import com.example.imtoken.modules.main.MainActivity

class WelcomeActivity :
    BaseActivity<WelcomeViewModel, ActivityWelcomeBinding>(WelcomeViewModel::class.java) {

    private var isLogin = false

    override fun initLayoutId(): Int {
        return R.layout.activity_welcome
    }

    override fun init() {
        initBar(false, R.color.welcomeBgColor)
        isLogin = SPUtils.getInstance(SpHelps.APP).getBoolean(SpHelps.APP_LOGIN, false)
//        viewModel.getCreateData(isLogin)
        time.start()
    }

    private val time = object : CountDownTimer(2 * 1000, 1000) {
        override fun onTick(millisUntilFinished: Long) {

        }

        override fun onFinish() {
            if (isLogin) {
                ActivityUtils.startActivity(MainActivity::class.java)
            } else {
                ActivityUtils.startActivity(LoginActivity::class.java)
            }
            finish()
        }

    }

}